// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

TestCase := Rectangle {
    property <int> touch1;
    property <int> touch2;
    property <int> touch3;

    property <string> pointer-event-test;

    TouchArea {
        x: 100phx;
        y: 100phx;
        width: 10phx;
        height: 10phx;
        clicked => { touch1+=1; }
        mouse-cursor: move;
        TouchArea {
            y: 2phx;
            height: 2phx;
            x: 3phx;
            width: 4phx;
            clicked => { touch3+=1; }
            mouse-cursor: default;
        }
    }
    TouchArea {
        x: 100phx;
        y: 100phx;
        width: 5phx;
        height: 5phx;
        mouse-cursor: pointer;
        clicked => {
            pointer-event-test += "click";
            touch2+=1;
        }
        pointer-event(e) => {
            if (e.kind == PointerEventKind.cancel) {
                pointer-event-test += "cancel";
            } else if (e.kind == PointerEventKind.up) {
                pointer-event-test += "up";
            } else if (e.kind == PointerEventKind.down) {
                pointer-event-test += "down";
            } else {
                pointer-event-test += "err";
            }
            if (e.button == PointerEventButton.right) {
                pointer-event-test += "right";
            } else if (e.button == PointerEventButton.left) {
                pointer-event-test += "left";
            } else if (e.button == PointerEventButton.middle) {
                pointer-event-test += "middle";
            } else if (e.button == PointerEventButton.other) {
                pointer-event-test += "other";
            } else {
                pointer-event-test += "???";
            }
        }
    }
}

/*
```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;

// does not click on anything
slint_testing::send_mouse_click(&instance, 5., 5.);
assert_eq(instance.get_touch1(), 0);
assert_eq(instance.get_touch2(), 0);
assert_eq(instance.get_touch3(), 0);

// click on second one
slint_testing::send_mouse_click(&instance, 101., 101.);
assert_eq(instance.get_touch1(), 0);
assert_eq(instance.get_touch2(), 1);
assert_eq(instance.get_touch3(), 0);

// click on first one only
slint_testing::send_mouse_click(&instance, 108., 108.);
assert_eq(instance.get_touch1(), 1);
assert_eq(instance.get_touch2(), 1);
assert_eq(instance.get_touch3(), 0);

// click on the third
slint_testing::send_mouse_click(&instance, 106., 103.);
assert_eq(instance.get_touch1(), 1);
assert_eq(instance.get_touch2(), 1);
assert_eq(instance.get_touch3(), 1);

assert_eq(instance.get_pointer_event_test(), "downleftclickupleft");

```


```rust
let instance = TestCase::new().unwrap();
// does not click on anything
slint_testing::send_mouse_click(&instance, 5., 5.);
assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_touch2(), 0);
assert_eq!(instance.get_touch3(), 0);

// click on second one
slint_testing::send_mouse_click(&instance, 101., 101.);
assert_eq!(instance.get_touch1(), 0);
assert_eq!(instance.get_touch2(), 1);
assert_eq!(instance.get_touch3(), 0);

// click on first one only
slint_testing::send_mouse_click(&instance, 108., 108.);
assert_eq!(instance.get_touch1(), 1);
assert_eq!(instance.get_touch2(), 1);
assert_eq!(instance.get_touch3(), 0);

// click on the third
slint_testing::send_mouse_click(&instance, 106., 103.);
assert_eq!(instance.get_touch1(), 1);
assert_eq!(instance.get_touch2(), 1);
assert_eq!(instance.get_touch3(), 1);

assert_eq!(instance.get_pointer_event_test().as_str(), "downleftclickupleft");

```

```js
var instance = new slint.TestCase();
// does not click on anything
instance.send_mouse_click(5., 5.);
assert.equal(instance.touch1, 0);
assert.equal(instance.touch2, 0);
assert.equal(instance.touch3, 0);

// click on second one
instance.send_mouse_click(101., 101.);
assert.equal(instance.touch1, 0);
assert.equal(instance.touch2, 1);
assert.equal(instance.touch3, 0);

// click on first one only
instance.send_mouse_click(108., 108.);
assert.equal(instance.touch1, 1);
assert.equal(instance.touch2, 1);
assert.equal(instance.touch3, 0);

// click on the third
instance.send_mouse_click(106., 103.);
assert.equal(instance.touch1, 1);
assert.equal(instance.touch2, 1);
assert.equal(instance.touch3, 1);

assert.equal(instance.pointer_event_test, "downleftclickupleft");
```
*/
